package com.id.coinscleaner.utils

import java.text.DecimalFormat

/**
 * Created by YiGo on 2022/7/11.
 */
val df2 = DecimalFormat("0.00")
fun smartChangeUint(size: Long): String {
    if (size / (1024 * 1024 * 1024) > 0) {
        return "GB"
    } else if (size / (1024 * 1024) > 0) {
        return "MB"
    } else if (size / 1024 > 0) {
        return "KB"
    } else {
        return "B"
    }
}

fun caculate(unit: String, size: Long): String {
    when (unit) {
        "GB" -> {
            return df2.format(size / (1024 * 1024 * 1024).toFloat())
        }
        "MB" -> {
            return df2.format(size / (1024 * 1024).toFloat())
        }
        "KB" -> {
            return df2.format((size / 1024).toFloat())
        }
        else -> return "0.00"
    }
}